import { fetchLogList,doEmptyLog } from '@/services/operationLog';
export default {
  namespace:'operationLog',
  state: {
    total:0,
    items:[],
    loading:true
  },
  effects: {
    *getLogList({ payload, callback }, { call, put }) {
      const response = yield call(fetchLogList, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *emptyLog({ payload, callback }, { call, put }) {
      const response = yield call(doEmptyLog, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },

  },

  reducers: {
    save(state, { payload }) {
      return {
        ...state,
        ...payload,
      };
    },
  },
};
